package rsj.api.product;

import com.rlyy.aibase.utils.base.Box;
import com.rlyy.aibase.utils.base.MapNode;
import common.util.Assert;
import common.util.BoxUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import rsj.api.user.BaseLink;
import rsj.log.ModuleEnum;
import rsj.log.OperationLog;
import rsj.log.OperationTypeEnum;
import rsj.service.ProductService;
@RestController
public class DoProductUpdate extends BaseLink {

    @Autowired
    private ProductService productService;

    @RequestMapping(value = "rsj_prod_update")
    @OperationLog(description = "修改产品", logType = OperationTypeEnum.UPDATE, logModule = ModuleEnum.PRODUCT_MANAGEMENT)
    public Box executeLink(Box in){
        MapNode data = in.getMapNode("data");
        Assert.isNotNull(data, "没有收到要更新的信息！");

        String id = productService.insertOrUpdate(data);

        return BoxUtil.successBox(in, "更新成功！").putNode("id", id);
    }

}
